package com.tf.integrated.config;

import com.tf.integrated.entity.*;
import com.tf.integrated.service.*;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URI;
import java.nio.ByteBuffer;

public class WarResultWebSocketClient extends WebSocketClient
{
    private static final Logger LOGGER = LoggerFactory.getLogger(WarResultWebSocketClient.class);
    private String mDevic = null;
    private WarningresultbikepicwarndbtService<WarningresultbikepicwarndbtEntity> bikepicwarndbtService;
    private WarningresultbikestrwarningstService<WarningresultbikestrwarningstEntity> bikestrwarningstService;
    private WarningresultfacelibInfodbtService<WarningresultfacelibInfodbtEntity> facelibInfodbtService;
    private WarningresultfacepicwarndbtService<WarningresultfacepicwarndbtEntity> facepicwarndbtService;
    private WarningresultpedpicwarndbtService<WarningresultpedpicwarndbtEntity> pedpicwarndbtService;
    private WarningresultpedstrwarningstService<WarningresultpedstrwarningstEntity> pedstrwarningstService;
    private WarningresulttripicwarndbtService<WarningresulttripicwarndbtEntity> tripicwarndbtService;
    private WarningresultvehlicwarndbtService<WarningresultvehlicwarndbtEntity> vehlicwarndbtService;
    private WarningresultvehpicwarndbtService<WarningresultvehpicwarndbtEntity> vehpicwarndbtService;
    private WarningresultvehstrwarningstService<WarningresultvehstrwarningstEntity> vehstrwarningstService;
    private WarningresultfacestrinfodbtService<WarningresultfacestrinfodbtEntity> facestrinfodbtService;
    private WarningresultbikesinfoService<WarningresultbikesinfoEntity> warningresultbikesinfoService;
    private WarningresultpersonService<WarningresultpersonEntity> warningresultpersonService;
    private WarningresultvehicleinfoService<WarningresultvehicleinfoEntity> warningresultvehicleinfoService;
    private WarningresultpedestriansinfoService<WarningresultpedestriansinfoEntity> warningresultpedestriansinfoService;
    private WarningresulttricyclesinfoService<WarningresulttricyclesinfoEntity> warningresulttricyclesinfoService;

    public WarResultWebSocketClient(URI serverUri) {
        super(serverUri);
    }

    public void setWarningresultbikesinfoService(WarningresultbikesinfoService<WarningresultbikesinfoEntity> warningresultbikesinfoService) {
        this.warningresultbikesinfoService = warningresultbikesinfoService;
    }

    public void setWarningresultpersonService(WarningresultpersonService<WarningresultpersonEntity> warningresultpersonService) {
        this.warningresultpersonService = warningresultpersonService;
    }

    public void setWarningresultvehicleinfoService(WarningresultvehicleinfoService<WarningresultvehicleinfoEntity> warningresultvehicleinfoService) {
        this.warningresultvehicleinfoService = warningresultvehicleinfoService;
    }

    public void setWarningresultpedestriansinfoService(WarningresultpedestriansinfoService<WarningresultpedestriansinfoEntity> warningresultpedestriansinfoService) {
        this.warningresultpedestriansinfoService = warningresultpedestriansinfoService;
    }

    public void setWarningresulttricyclesinfoService(WarningresulttricyclesinfoService<WarningresulttricyclesinfoEntity> warningresulttricyclesinfoService) {
        this.warningresulttricyclesinfoService = warningresulttricyclesinfoService;
    }

    public void setBikepicwarndbtService(WarningresultbikepicwarndbtService<WarningresultbikepicwarndbtEntity> bikepicwarndbtService) {
        this.bikepicwarndbtService = bikepicwarndbtService;
    }

    public void setBikestrwarningstService(WarningresultbikestrwarningstService<WarningresultbikestrwarningstEntity> bikestrwarningstService) {
        this.bikestrwarningstService = bikestrwarningstService;
    }

    public void setFacelibInfodbtService(WarningresultfacelibInfodbtService<WarningresultfacelibInfodbtEntity> facelibInfodbtService) {
        this.facelibInfodbtService = facelibInfodbtService;
    }

    public void setFacepicwarndbtService(WarningresultfacepicwarndbtService<WarningresultfacepicwarndbtEntity> facepicwarndbtService) {
        this.facepicwarndbtService = facepicwarndbtService;
    }

    public void setPedpicwarndbtService(WarningresultpedpicwarndbtService<WarningresultpedpicwarndbtEntity> pedpicwarndbtService) {
        this.pedpicwarndbtService = pedpicwarndbtService;
    }

    public void setPedstrwarningstService(WarningresultpedstrwarningstService<WarningresultpedstrwarningstEntity> pedstrwarningstService) {
        this.pedstrwarningstService = pedstrwarningstService;
    }

    public void setTripicwarndbtService(WarningresulttripicwarndbtService<WarningresulttripicwarndbtEntity> tripicwarndbtService) {
        this.tripicwarndbtService = tripicwarndbtService;
    }

    public void setVehlicwarndbtService(WarningresultvehlicwarndbtService<WarningresultvehlicwarndbtEntity> vehlicwarndbtService) {
        this.vehlicwarndbtService = vehlicwarndbtService;
    }

    public void setVehpicwarndbtService(WarningresultvehpicwarndbtService<WarningresultvehpicwarndbtEntity> vehpicwarndbtService) {
        this.vehpicwarndbtService = vehpicwarndbtService;
    }

    public void setVehstrwarningstService(WarningresultvehstrwarningstService<WarningresultvehstrwarningstEntity> vehstrwarningstService) {
        this.vehstrwarningstService = vehstrwarningstService;
    }

    public void setFacestrinfodbtService(WarningresultfacestrinfodbtService<WarningresultfacestrinfodbtEntity> facestrinfodbtService) {
        this.facestrinfodbtService = facestrinfodbtService;
    }

    public void setmDevic(String mDevic)
    {
        this.mDevic = mDevic;
    }

    @Override
    public void onOpen(ServerHandshake arg0)
    {
        // TODO Auto-generated method stub
        LOGGER.info("------ WarResultWebSocketClient onOpen ------");
    }

    @Override
    public void onClose(int arg0, String arg1, boolean arg2)
    {
        // TODO Auto-generated method stub
        LOGGER.info("------ WarResultWebSocketClient onClose ------{}",arg1);
    }

    @Override
    public void onError(Exception arg0) {
        // TODO Auto-generated method stub
        LOGGER.info("------ WarResultWebSocketClient onError ------{}",arg0);
    }

    @Override
    public void onMessage(String arg0) {
        // TODO Auto-generated method stub
        //LOGGER.info("--------WarResultWebSocketClient 接收到服务端数据String： " + arg0 + "--------");
    }

    @Override
    public void onMessage(ByteBuffer arg0)
    {
        // TODO Auto-generated method stub
       // LOGGER.info("-------- WarResultWebSocketClient 接收到服务端数据ByteBuffer： " + arg0 + "--------");
        byte[] arr = new byte[arg0.remaining()];
        arg0.get(arr);
        // TODO Auto-generated method stub
        int headlen = Config.readInt32BE(arr,0);
        String headval = Config.readString(arr,4,headlen);
        LOGGER.info("-------- WarResultWebSocketClient headval： " + headval + "--------");
        try
        {
            JSONObject jsonhead = new JSONObject(headval);
            int Channel = jsonhead.optInt("Channel");
            int ResultLen = jsonhead.optInt("ResultLen");
            int ObjPictureLen = jsonhead.optInt("ObjPictureLen");
            int FullPictureLen = jsonhead.optInt("FullPictureLen");
            int ResultType = jsonhead.optInt("ResultType");
            int WarnPictureLen = jsonhead.optInt("WarnPictureLen");
            int WarningInfoLen = jsonhead.optInt("WarningInfoLen");
            int WarningType = jsonhead.optInt("WarningType");
            String ObjPicturePath = null;
            String FullPicturePath = null;
            String WaringPicturePath = null;
            String Resultval = Config.readString(arr,headlen+4,ResultLen);
            if (ObjPictureLen>0)
            {
                byte[] buff = new byte[ObjPictureLen];
                for (int i = 0; i < buff.length; i++)
                {
                    buff[i] = arr[headlen+4+ResultLen+i];
                }
                String  tmpfilename = "WAROBJP"+System.currentTimeMillis()+".jpg";
                String  tmppath = Config.getMimgpath() + tmpfilename;
                Config.saveFile(tmppath,buff);
                ObjPicturePath = Config.getMurlpath() + tmpfilename;
            }
            if (FullPictureLen>0)
            {
                byte[] buff = new byte[FullPictureLen];
                for (int i = 0; i < buff.length; i++)
                {
                    buff[i] = arr[headlen+4+ResultLen+ObjPictureLen+i];
                }
                String  tmpfilename = "WARFULLP"+System.currentTimeMillis()+".jpg";
                String  tmppath = Config.getMimgpath() + tmpfilename;
                Config.saveFile(tmppath,buff);
                FullPicturePath = Config.getMurlpath() + tmpfilename;
            }
            String WarningInfoVal = Config.readString(arr,headlen+4+ResultLen+ObjPictureLen+FullPictureLen,WarningInfoLen);
            if (WarnPictureLen>0)
            {
                byte[] buff = new byte[WarnPictureLen];
                for (int i = 0; i < buff.length; i++)
                {
                    buff[i] = arr[headlen+4+ResultLen+ObjPictureLen+FullPictureLen+WarningInfoLen+i];
                }
                String  tmpfilename = "WARPICALL"+System.currentTimeMillis()+".jpg";
                String  tmppath = Config.getMimgpath() + tmpfilename;
                Config.saveFile(tmppath,buff);
                WaringPicturePath = Config.getMurlpath() + tmpfilename;
            }
            if(ResultType==1)
            {
                parseMessgedatavehicleinfo(Resultval,ObjPicturePath,FullPicturePath);
            }
            else if(ResultType==2)
            {
                parseMessgedatatricyclesinfo(Resultval,ObjPicturePath,FullPicturePath);
            }
            else if(ResultType==3)
            {
                parseMessgedatapedestriansinfo(Resultval,ObjPicturePath,FullPicturePath);
            }
            else if(ResultType==4)
            {
                parseMessgedatabikesinfo(Resultval,ObjPicturePath,FullPicturePath);
            }
            else if(ResultType==5)
            {
                parseMessgedataperson(Resultval,ObjPicturePath,FullPicturePath);
            }
            parseWaringinfoMessgedata(WarningInfoVal,WaringPicturePath,WarningType,Channel,ObjPicturePath,FullPicturePath);
        }
        catch (Exception e)
        {

        }
    }
    //解析预警结构化数据
    private void parseWaringinfoMessgedata(String WarningInfoVal,String WaringPicturePath,int WarningType,int chn,String ObjPicturePath,String FullPicturePath)
    {
        if(WarningType==1)
        {//ok
            parseWaringVehStrDesc_st(WarningInfoVal,WaringPicturePath,chn,ObjPicturePath,FullPicturePath);
        }
        else if(WarningType==2)
        {//ok
            parseWaringVehPicWarnDbt(WarningInfoVal,WaringPicturePath,chn,ObjPicturePath,FullPicturePath);
        }
        else if(WarningType==3)
        {
            parseWaringVehLICDesc_st(WarningInfoVal,WaringPicturePath,chn,ObjPicturePath,FullPicturePath);
        }
        else if(WarningType==4)
        {
            parseWaringTriPicWarnDbt(WarningInfoVal,WaringPicturePath,chn,ObjPicturePath,FullPicturePath);
        }
        else if(WarningType==5)
        {
            parseWaringPedStrWarning_st(WarningInfoVal,WaringPicturePath,chn,ObjPicturePath,FullPicturePath);
        }
        else if(WarningType==6)
        {
            parseWaringPedPicWarnDbt(WarningInfoVal,WaringPicturePath,chn,ObjPicturePath,FullPicturePath);
        }
        else if(WarningType==7)
        {
            parseWaringBikeStrWarning_st(WarningInfoVal,WaringPicturePath,chn,ObjPicturePath,FullPicturePath);
        }
        else if(WarningType==8)
        {
            parseWaringBikePicWarnDbt(WarningInfoVal,WaringPicturePath,chn,ObjPicturePath,FullPicturePath);
        }
        else if(WarningType==9)
        {
            parseWaringFacePicWarnDbt(WarningInfoVal,WaringPicturePath,chn,ObjPicturePath,FullPicturePath);
        }
        else if(WarningType==10)
        {//ok
            parseWaringFaceLibInfoDbt(WarningInfoVal,WaringPicturePath,chn,ObjPicturePath,FullPicturePath);
        }
        else if(WarningType==11)
        {//ok
            parseWaringFaceStrWarnDbt(WarningInfoVal,WaringPicturePath,chn,ObjPicturePath,FullPicturePath);
        }
    }
    //解析预警结构化数据车辆属性布控
    private void parseWaringVehLICDesc_st(String WarningInfoVal,String WaringPicturePath,int chn,String ObjPicturePath,String FullPicturePath)
    {
        if (WarningInfoVal != null && WarningInfoVal.equals("")==false)
        {
            try
            {
                WarningresultvehlicwarndbtEntity evvehety = new WarningresultvehlicwarndbtEntity();
                JSONObject Resultvaljson = new JSONObject(WarningInfoVal);
                String Licence = Resultvaljson.optString("Licence");
                evvehety.setLicence(Licence);
                int Id = Resultvaljson.optInt("Id");
                evvehety.setUid(Id);
                String Name = Resultvaljson.optString("Name");
                evvehety.setName(Name);
                String Reason = Resultvaljson.optString("Reason");
                evvehety.setReason(Reason);
                String Time = Resultvaljson.optString("Time");
                evvehety.setTime(Time);
                evvehety.setChn(chn+"");
                evvehety.setObjpicpath(ObjPicturePath);
                evvehety.setFullpicpath(FullPicturePath);
                evvehety.setWarningpicpath(WaringPicturePath);
                evvehety.setDeviceid(mDevic);
                vehlicwarndbtService.insert(evvehety);
                LOGGER.info("-------- parseWaringVehLICDesc_st mDevic： " + mDevic + "--------");
            }
            catch (Exception e)
            {

            }
        }
    }
    //解析预警结构化数据两轮车图片布控
    private void parseWaringBikePicWarnDbt(String WarningInfoVal,String WaringPicturePath,int chn,String ObjPicturePath,String FullPicturePath)
    {
        if (WarningInfoVal != null && WarningInfoVal.equals("")==false)
        {
            try
            {
                WarningresultbikepicwarndbtEntity evvehety = new WarningresultbikepicwarndbtEntity();
                JSONObject Resultvaljson = new JSONObject(WarningInfoVal);
                String Desc = Resultvaljson.optString("Desc");
                evvehety.setDesc(Desc);
                int Id = Resultvaljson.optInt("Id");
                evvehety.setUid(Id);
                String Name = Resultvaljson.optString("Name");
                evvehety.setName(Name);
                String Reason = Resultvaljson.optString("Reason");
                evvehety.setReason(Reason);
                double Similarity = Resultvaljson.optDouble("Similarity");
                evvehety.setSimilarity(Similarity);
                double Sumsquares = Resultvaljson.optDouble("Sumsquares");
                evvehety.setSumsquares((float)Sumsquares);
                double Threshold = Resultvaljson.optDouble("Threshold");
                evvehety.setThreshold(Threshold);
                String Time = Resultvaljson.optString("Time");
                evvehety.setTime(Time);
                evvehety.setChn(chn+"");
                evvehety.setObjpicpath(ObjPicturePath);
                evvehety.setFullpicpath(FullPicturePath);
                evvehety.setWarningpicpath(WaringPicturePath);
                evvehety.setDeviceid(mDevic);
                bikepicwarndbtService.insert(evvehety);
                LOGGER.info("-------- parseWaringBikePicWarnDbt mDevic： " + mDevic + "--------");
            }
            catch (Exception e)
            {

            }
        }
    }
    //解析预警结构化数据两轮车属性布控
    private void parseWaringBikeStrWarning_st(String WarningInfoVal,String WaringPicturePath,int chn,String ObjPicturePath,String FullPicturePath)
    {
        if (WarningInfoVal != null && WarningInfoVal.equals("")==false)
        {
            try
            {
                WarningresultbikestrwarningstEntity evvehety = new WarningresultbikestrwarningstEntity();
                JSONObject Resultvaljson = new JSONObject(WarningInfoVal);
                int Id = Resultvaljson.optInt("Id");
                evvehety.setUid(Id);
                String BikeStrDesc = Resultvaljson.optJSONObject("BikeStrDesc").toString();
                evvehety.setBikestrdesc(BikeStrDesc);
                String Name = Resultvaljson.optString("Name");
                evvehety.setName(Name);
                String Reason = Resultvaljson.optString("Reason");
                evvehety.setReason(Reason);
                String Time = Resultvaljson.optString("Time");
                evvehety.setTime(Time);
                evvehety.setChn(chn+"");
                evvehety.setObjpicpath(ObjPicturePath);
                evvehety.setFullpicpath(FullPicturePath);
                evvehety.setWarningpicpath(WaringPicturePath);
                evvehety.setDeviceid(mDevic);
                bikestrwarningstService.insert(evvehety);
                LOGGER.info("-------- parseWaringBikeStrWarning_st mDevic： " + mDevic + "--------");
            }
            catch (Exception e)
            {

            }
        }
    }
    //解析预警结构化数据人脸结构化布控-普通模式
    private void parseWaringFaceStrWarnDbt(String WarningInfoVal,String WaringPicturePath,int chn,String ObjPicturePath,String FullPicturePath)
    {
        if (WarningInfoVal != null && WarningInfoVal.equals("")==false)
        {
            try
            {
                WarningresultfacestrinfodbtEntity evvehety = new WarningresultfacestrinfodbtEntity();
                JSONObject Resultvaljson = new JSONObject(WarningInfoVal);
                int Id = Resultvaljson.optInt("Id");
                evvehety.setUid(Id);
                String Name = Resultvaljson.optString("Name");
                evvehety.setName(Name);
                String Reason = Resultvaljson.optString("Reason");
                evvehety.setReason(Reason);
                String Time = Resultvaljson.optString("Time");
                evvehety.setTime(Time);
                String FaceStrDesc = Resultvaljson.optJSONObject("FaceStrDesc").toString();
                evvehety.setFacestrdesc(FaceStrDesc);
                evvehety.setChn(chn+"");
                evvehety.setObjpicpath(ObjPicturePath);
                evvehety.setFullpicpath(FullPicturePath);
                evvehety.setWarningpicpath(WaringPicturePath);
                evvehety.setDeviceid(mDevic);
                facestrinfodbtService.insert(evvehety);
                LOGGER.info("-------- parseWaringFaceStrWarnDbt mDevic： " + mDevic + "--------");
            }
            catch (Exception e)
            {

            }
        }
    }
    //解析预警结构化数据人脸陌生人模式
    private void parseWaringFaceLibInfoDbt(String WarningInfoVal,String WaringPicturePath,int chn,String ObjPicturePath,String FullPicturePath)
    {
        if (WarningInfoVal != null && WarningInfoVal.equals("")==false)
        {
            try
            {
                WarningresultfacelibInfodbtEntity evvehety = new WarningresultfacelibInfodbtEntity();
                JSONObject Resultvaljson = new JSONObject(WarningInfoVal);
                boolean vEnable = Resultvaljson.optBoolean("Enable");
                int Enable = 0;
                if (vEnable == true)
                {
                    Enable = 1;
                }
                evvehety.setEnable(Enable);

                boolean vStrangerMode = Resultvaljson.optBoolean("StrangerMode");
                int StrangerMode = 0;
                if (vStrangerMode == true)
                {
                    StrangerMode = 1;
                }
                evvehety.setStrangermode(StrangerMode);
                int Id = Resultvaljson.optInt("Id");
                evvehety.setUid(Id);
                String Name = Resultvaljson.optString("Name");
                evvehety.setName(Name);
                String Reason = Resultvaljson.optString("Reason");
                evvehety.setReason(Reason);
                int TotalMem = Resultvaljson.optInt("TotalMem");
                evvehety.setTotalmem(TotalMem);
                String Time = Resultvaljson.optString("Time");
                evvehety.setTime(Time);
                evvehety.setChn(chn+"");
                evvehety.setObjpicpath(ObjPicturePath);
                evvehety.setFullpicpath(FullPicturePath);
                evvehety.setWarningpicpath(WaringPicturePath);
                evvehety.setDeviceid(mDevic);
                facelibInfodbtService.insert(evvehety);
                LOGGER.info("-------- parseWaringFaceLibInfoDbt mDevic： " + mDevic + "--------");
            }
            catch (Exception e)
            {

            }
        }
    }
    //解析预警结构化数据人脸图片布控-普通模式
    private void parseWaringFacePicWarnDbt(String WarningInfoVal,String WaringPicturePath,int chn,String ObjPicturePath,String FullPicturePath)
    {
        if (WarningInfoVal != null && WarningInfoVal.equals("")==false)
        {
            try
            {
                WarningresultfacepicwarndbtEntity evvehety = new WarningresultfacepicwarndbtEntity();
                JSONObject Resultvaljson = new JSONObject(WarningInfoVal);
                int Id = Resultvaljson.optInt("Id");
                evvehety.setUid(Id);
                int LibId = Resultvaljson.optInt("LibId");
                evvehety.setLibid(LibId);
                int Sex = Resultvaljson.optInt("Sex");
                evvehety.setSex(Sex);
                String Name = Resultvaljson.optString("Name");
                evvehety.setName(Name);
                double Similarity = Resultvaljson.optDouble("Similarity");
                evvehety.setSimilarity(Similarity);
                double Sumsquares = Resultvaljson.optDouble("Sumsquares");
                evvehety.setSumsquares((float)Sumsquares);
                double Threshold = Resultvaljson.optDouble("Threshold");
                evvehety.setThreshold(Threshold);
                String Time = Resultvaljson.optString("Time");
                evvehety.setTime(Time);
                String Address = Resultvaljson.optString("Address");
                evvehety.setAddress(Address);
                String Birthday = Resultvaljson.optString("Birthday");
                evvehety.setBirthday(Birthday);
                String IDNumber = Resultvaljson.optString("IDNumber");
                evvehety.setIdnumber(IDNumber);
                evvehety.setChn(chn+"");
                evvehety.setObjpicpath(ObjPicturePath);
                evvehety.setFullpicpath(FullPicturePath);
                evvehety.setWarningpicpath(WaringPicturePath);
                evvehety.setDeviceid(mDevic);
                facepicwarndbtService.insert(evvehety);
                LOGGER.info("-------- parseWaringFacePicWarnDbt mDevic： " + mDevic + "--------");
            }
            catch (Exception e)
            {

            }
        }
    }
    //解析预警结构化数据行人图片布控
    private void parseWaringPedPicWarnDbt(String WarningInfoVal,String WaringPicturePath,int chn,String ObjPicturePath,String FullPicturePath)
    {
        if (WarningInfoVal != null && WarningInfoVal.equals("")==false)
        {
            try
            {
                WarningresultpedpicwarndbtEntity evvehety = new WarningresultpedpicwarndbtEntity();
                JSONObject Resultvaljson = new JSONObject(WarningInfoVal);
                String Desc = Resultvaljson.optString("Desc");
                evvehety.setDesc(Desc);
                int Id = Resultvaljson.optInt("Id");
                evvehety.setUid(Id);
                String Name = Resultvaljson.optString("Name");
                evvehety.setName(Name);
                String Reason = Resultvaljson.optString("Reason");
                evvehety.setReason(Reason);
                double Similarity = Resultvaljson.optDouble("Similarity");
                evvehety.setSimilarity(Similarity);
                double Sumsquares = Resultvaljson.optDouble("Sumsquares");
                evvehety.setSumsquares((float)Sumsquares);
                double Threshold = Resultvaljson.optDouble("Threshold");
                evvehety.setThreshold(Threshold);
                String Time = Resultvaljson.optString("Time");
                evvehety.setTime(Time);
                evvehety.setChn(chn+"");
                evvehety.setObjpicpath(ObjPicturePath);
                evvehety.setFullpicpath(FullPicturePath);
                evvehety.setWarningpicpath(WaringPicturePath);
                evvehety.setDeviceid(mDevic);
                pedpicwarndbtService.insert(evvehety);
                LOGGER.info("-------- parseWaringVehPicWarnDbt mDevic： " + mDevic + "--------");
            }
            catch (Exception e)
            {

            }
        }
    }
    //解析预警结构化数据行人属性布控
    private void parseWaringPedStrWarning_st(String WarningInfoVal,String WaringPicturePath,int chn,String ObjPicturePath,String FullPicturePath)
    {
        if (WarningInfoVal != null && WarningInfoVal.equals("")==false)
        {
            try
            {
                WarningresultpedstrwarningstEntity evvehety = new WarningresultpedstrwarningstEntity();
                JSONObject Resultvaljson = new JSONObject(WarningInfoVal);
                int Id = Resultvaljson.optInt("Id");
                evvehety.setUid(Id);
                String PedStrDesc = Resultvaljson.optJSONObject("PedStrDesc").toString();
                evvehety.setPedstrdesc(PedStrDesc);
                String Name = Resultvaljson.optString("Name");
                evvehety.setName(Name);
                String Reason = Resultvaljson.optString("Reason");
                evvehety.setReason(Reason);
                String Time = Resultvaljson.optString("Time");
                evvehety.setTime(Time);
                evvehety.setChn(chn+"");
                evvehety.setObjpicpath(ObjPicturePath);
                evvehety.setFullpicpath(FullPicturePath);
                evvehety.setWarningpicpath(WaringPicturePath);
                evvehety.setDeviceid(mDevic);
                pedstrwarningstService.insert(evvehety);
                LOGGER.info("-------- parseWaringPedStrWarning_st mDevic： " + mDevic + "--------");
            }
            catch (Exception e)
            {

            }
        }
    }
    //解析预警结构化数据车辆属性布控
    private void parseWaringVehStrDesc_st(String WarningInfoVal,String WaringPicturePath,int chn,String ObjPicturePath,String FullPicturePath)
    {
        if (WarningInfoVal != null && WarningInfoVal.equals("")==false)
        {
            try
            {
                WarningresultvehstrwarningstEntity evvehety = new WarningresultvehstrwarningstEntity();
                JSONObject Resultvaljson = new JSONObject(WarningInfoVal);
                String Licence = Resultvaljson.optString("Licence");
                evvehety.setLicence(Licence);
                int Id = Resultvaljson.optInt("Id");
                evvehety.setUid(Id);
                String VehStrDesc = Resultvaljson.optJSONObject("VehStrDesc").toString();
                evvehety.setVehstrdesc(VehStrDesc);
                String Name = Resultvaljson.optString("Name");
                evvehety.setName(Name);
                String Reason = Resultvaljson.optString("Reason");
                evvehety.setReason(Reason);
                String Time = Resultvaljson.optString("Time");
                evvehety.setTime(Time);
                evvehety.setObjpicpath(ObjPicturePath);
                evvehety.setFullpicpath(FullPicturePath);
                evvehety.setWarningpicpath(WaringPicturePath);
                evvehety.setChn(chn+"");
                evvehety.setObjpicpath(ObjPicturePath);
                evvehety.setFullpicpath(FullPicturePath);
                evvehety.setWarningpicpath(WaringPicturePath);
                evvehety.setDeviceid(mDevic);
                vehstrwarningstService.insert(evvehety);
                LOGGER.info("-------- parseWaringVehStrDesc_st mDevic： " + mDevic + "--------");
            }
            catch (Exception e)
            {

            }
        }
    }
    //解析预警结构化数据车辆图片布控
    private void parseWaringVehPicWarnDbt(String WarningInfoVal,String WaringPicturePath,int chn,String ObjPicturePath,String FullPicturePath)
    {
        if (WarningInfoVal != null && WarningInfoVal.equals("")==false)
        {
            try
            {
                WarningresultvehpicwarndbtEntity evvehety = new WarningresultvehpicwarndbtEntity();
                JSONObject Resultvaljson = new JSONObject(WarningInfoVal);
                String Desc = Resultvaljson.optString("Desc");
                evvehety.setDesc(Desc);
                int Id = Resultvaljson.optInt("Id");
                evvehety.setUid(Id);
                String Name = Resultvaljson.optString("Name");
                evvehety.setName(Name);
                String Reason = Resultvaljson.optString("Reason");
                evvehety.setReason(Reason);
                double Similarity = Resultvaljson.optDouble("Similarity");
                evvehety.setSimilarity(Similarity);
                double Sumsquares = Resultvaljson.optDouble("Sumsquares");
                evvehety.setSumsquares((float)Sumsquares);
                double Threshold = Resultvaljson.optDouble("Threshold");
                evvehety.setThreshold(Threshold);
                String Time = Resultvaljson.optString("Time");
                evvehety.setTime(Time);
                evvehety.setChn(chn+"");
                evvehety.setObjpicpath(ObjPicturePath);
                evvehety.setFullpicpath(FullPicturePath);
                evvehety.setWarningpicpath(WaringPicturePath);
                evvehety.setDeviceid(mDevic);
                vehpicwarndbtService.insert(evvehety);
                LOGGER.info("-------- parseWaringVehPicWarnDbt mDevic： " + mDevic + "--------");
            }
            catch (Exception e)
            {

            }
        }
    }
    //解析预警结构化数据三轮车图片布控
    private void parseWaringTriPicWarnDbt(String WarningInfoVal,String WaringPicturePath,int chn,String ObjPicturePath,String FullPicturePath)
    {
        if (WarningInfoVal != null && WarningInfoVal.equals("")==false)
        {
            try
            {
                WarningresulttripicwarndbtEntity evvehety = new WarningresulttripicwarndbtEntity();
                JSONObject Resultvaljson = new JSONObject(WarningInfoVal);
                String Desc = Resultvaljson.optString("Desc");
                evvehety.setDesc(Desc);
                int Id = Resultvaljson.optInt("Id");
                evvehety.setUid(Id);
                String Name = Resultvaljson.optString("Name");
                evvehety.setName(Name);
                String Reason = Resultvaljson.optString("Reason");
                evvehety.setReason(Reason);
                double Similarity = Resultvaljson.optDouble("Similarity");
                evvehety.setSimilarity(Similarity);
                double Sumsquares = Resultvaljson.optDouble("Sumsquares");
                evvehety.setSumsquares((float)Sumsquares);
                double Threshold = Resultvaljson.optDouble("Threshold");
                evvehety.setThreshold(Threshold);
                String Time = Resultvaljson.optString("Time");
                evvehety.setTime(Time);
                evvehety.setChn(chn+"");
                evvehety.setObjpicpath(ObjPicturePath);
                evvehety.setFullpicpath(FullPicturePath);
                evvehety.setWarningpicpath(WaringPicturePath);
                evvehety.setDeviceid(mDevic);
                tripicwarndbtService.insert(evvehety);
                LOGGER.info("-------- parseWaringTriPicWarnDbt mDevic： " + mDevic + "--------");
            }
            catch (Exception e)
            {

            }
        }
    }

    //解析订阅结构化数据(非机动车)
    private void parseMessgedatabikesinfo(String Resultval,String objpath,String fullpath)
    {
        if (Resultval != null && Resultval.equals("")==false)
        {
            try
            {
                WarningresultbikesinfoEntity evvehety = new WarningresultbikesinfoEntity();
                JSONObject Resultvaljson = new JSONObject(Resultval);
                String Time = Resultvaljson.optString("Time");
                evvehety.setTime(Time);
                String Rect = Resultvaljson.optJSONArray("Rect").toString();
                evvehety.setRect(Rect);
                String Chn = Resultvaljson.optString("Chn");
                evvehety.setChn(Chn);
                String Bag = Resultvaljson.optJSONObject("Bag").toString();
                evvehety.setBag(Bag);
                String BottomColor = Resultvaljson.optJSONObject("BottomColor").toString();
                evvehety.setBottomcolor(BottomColor);
                String BottomType = Resultvaljson.optJSONObject("BottomType").toString();
                evvehety.setBottomtype(BottomType);
                String DriveWay = Resultvaljson.optJSONObject("DriveWay").toString();
                evvehety.setDriveway(DriveWay);
                String Glasses = Resultvaljson.optJSONObject("Glasses").toString();
                evvehety.setGlasses(Glasses);
                String Hair = Resultvaljson.optJSONObject("Hair").toString();
                evvehety.setHair(Hair);
                String Hat = Resultvaljson.optJSONObject("Hat").toString();
                evvehety.setHat(Hat);
                String Age = Resultvaljson.optJSONObject("Age").toString();
                evvehety.setAge(Age);
                String Baby = Resultvaljson.optJSONObject("Baby").toString();
                evvehety.setBaby(Baby);
                String Knapsack = Resultvaljson.optJSONObject("Knapsack").toString();
                evvehety.setKnapsack(Knapsack);
                String Mask = Resultvaljson.optJSONObject("Mask").toString();
                evvehety.setMask(Mask);
                String MessengerBag = Resultvaljson.optJSONObject("MessengerBag").toString();
                evvehety.setMessengerbag(MessengerBag);
                String Orientation = Resultvaljson.optJSONObject("Orientation").toString();
                evvehety.setOrientation(Orientation);
                String Sex = Resultvaljson.optJSONObject("Sex").toString();
                evvehety.setSex(Sex);
                String ShoulderBag = Resultvaljson.optJSONObject("ShoulderBag").toString();
                evvehety.setShoulderaag(ShoulderBag);
                String Type = Resultvaljson.optJSONObject("Type").toString();
                evvehety.setType(Type);
                String Umbrella = Resultvaljson.optJSONObject("Umbrella").toString();
                evvehety.setUmbrella(Umbrella);
                String UpperColor = Resultvaljson.optJSONObject("UpperColor").toString();
                evvehety.setUppercolor(UpperColor);
                String UpperTexture = Resultvaljson.optJSONObject("UpperTexture").toString();
                evvehety.setUppertexture(UpperTexture);
                String UpperType = Resultvaljson.optJSONObject("UpperType").toString();
                evvehety.setUppertype(UpperType);
                evvehety.setFullpicpath(fullpath);
                evvehety.setObjpicpath(objpath);
                evvehety.setDeviceid(mDevic);
                warningresultbikesinfoService.insert(evvehety);
                LOGGER.info("-------- parseMessgedatabikesinfo mDevic： " + mDevic + "--------");
            }
            catch (Exception e)
            {

            }
        }
    }
    //解析订阅结构化数据(行人)
    private void parseMessgedatapedestriansinfo(String Resultval,String objpath,String fullpath)
    {
        if (Resultval != null && Resultval.equals("")==false)
        {
            try
            {
                WarningresultpedestriansinfoEntity evvehety = new WarningresultpedestriansinfoEntity();
                JSONObject Resultvaljson = new JSONObject(Resultval);
                String Time = Resultvaljson.optString("Time");
                evvehety.setTime(Time);
                String Rect = Resultvaljson.optJSONArray("Rect").toString();
                evvehety.setRect(Rect);
                String Chn = Resultvaljson.optString("Chn");
                evvehety.setChn(Chn);
                String Age = Resultvaljson.optJSONObject("Age").toString();
                evvehety.setAge(Age);
                String Baby = Resultvaljson.optJSONObject("Baby").toString();
                evvehety.setBaby(Baby);
                String Bag = Resultvaljson.optJSONObject("Bag").toString();
                evvehety.setBag(Bag);
                String BottomColor = Resultvaljson.optJSONObject("BottomColor").toString();
                evvehety.setBottomcolor(BottomColor);
                String BottomType = Resultvaljson.optJSONObject("BottomType").toString();
                evvehety.setBottomtype(BottomType);
                String DriveWay = Resultvaljson.optJSONObject("DriveWay").toString();
                evvehety.setDriveway(DriveWay);
                String Glasses = Resultvaljson.optJSONObject("Glasses").toString();
                evvehety.setGlasses(Glasses);
                String Hair = Resultvaljson.optJSONObject("Hair").toString();
                evvehety.setHair(Hair);
                String Hat = Resultvaljson.optJSONObject("Hat").toString();
                evvehety.setHat(Hat);
                String Knapsack = Resultvaljson.optJSONObject("Knapsack").toString();
                evvehety.setKnapsack(Knapsack);
                String Mask = Resultvaljson.optJSONObject("Mask").toString();
                evvehety.setMask(Mask);
                String MessengerBag = Resultvaljson.optJSONObject("MessengerBag").toString();
                evvehety.setMessengerbag(MessengerBag);
                String Orientation = Resultvaljson.optJSONObject("Orientation").toString();
                evvehety.setOrientation(Orientation);
                String Sex = Resultvaljson.optJSONObject("Sex").toString();
                evvehety.setSex(Sex);
                String ShoulderBag = Resultvaljson.optJSONObject("ShoulderBag").toString();
                evvehety.setShoulderaag(ShoulderBag);
                String Type = Resultvaljson.optJSONObject("Type").toString();
                evvehety.setType(Type);
                String Umbrella = Resultvaljson.optJSONObject("Umbrella").toString();
                evvehety.setUmbrella(Umbrella);
                String UpperColor = Resultvaljson.optJSONObject("UpperColor").toString();
                evvehety.setUppercolor(UpperColor);
                String UpperTexture = Resultvaljson.optJSONObject("UpperTexture").toString();
                evvehety.setUppertexture(UpperTexture);
                String UpperType = Resultvaljson.optJSONObject("UpperType").toString();
                evvehety.setUppertype(UpperType);
                evvehety.setFullpicpath(fullpath);
                evvehety.setObjpicpath(objpath);
                evvehety.setDeviceid(mDevic);
                warningresultpedestriansinfoService.insert(evvehety);
                LOGGER.info("-------- parseMessgedatapedestriansinfo mDevic： " + mDevic + "--------");
            }
            catch (Exception e)
            {

            }
        }
    }
    //解析订阅结构化数据(三轮车)
    private void parseMessgedatatricyclesinfo(String Resultval,String objpath,String fullpath)
    {
        if (Resultval != null && Resultval.equals("")==false)
        {
            try
            {
                WarningresulttricyclesinfoEntity evvehety = new WarningresulttricyclesinfoEntity();
                JSONObject Resultvaljson = new JSONObject(Resultval);
                String Convertible = Resultvaljson.optJSONObject("Convertible").toString();
                evvehety.setConvertible(Convertible);
                String Chn = Resultvaljson.optString("Chn");
                evvehety.setChn(Chn);
                String RoofColor = Resultvaljson.optJSONObject("RoofColor").toString();
                evvehety.setRoofcolor(RoofColor);
                String Type = Resultvaljson.optJSONObject("Type").toString();
                evvehety.setType(Type);
                String DriveWay = Resultvaljson.optJSONObject("DriveWay").toString();
                evvehety.setDriveway(DriveWay);
                String Manned = Resultvaljson.optJSONObject("Manned").toString();
                evvehety.setManned(Manned);
                String Time = Resultvaljson.optString("Time");
                evvehety.setTime(Time);
                String Rect = Resultvaljson.optJSONArray("Rect").toString();
                evvehety.setRect(Rect);
                evvehety.setFullpicpath(fullpath);
                evvehety.setObjpicpath(objpath);
                evvehety.setDeviceid(mDevic);
                warningresulttricyclesinfoService.insert(evvehety);
                LOGGER.info("-------- parseMessgedatatricyclesinfo mDevic： " + mDevic + "--------");
            }
            catch (Exception e)
            {

            }
        }
    }
    //解析订阅结构化数据(人脸)
    private void parseMessgedataperson(String Resultval,String objpath,String fullpath)
    {
        if (Resultval != null && Resultval.equals("")==false)
        {
            try
            {
                WarningresultpersonEntity evvehety = new WarningresultpersonEntity();
                JSONObject Resultvaljson = new JSONObject(Resultval);
                String Age = Resultvaljson.optJSONObject("Age").toString();
                evvehety.setAge(Age);
                String Chn = Resultvaljson.optString("Chn");
                evvehety.setChn(Chn);
                evvehety.setFullpicpath(fullpath);
                evvehety.setObjpicpath(objpath);
                String Time = Resultvaljson.optString("Time");
                evvehety.setTime(Time);
                String Rect = Resultvaljson.optJSONArray("Rect").toString();
                evvehety.setRect(Rect);
                String Glasses = Resultvaljson.optJSONObject("Glasses").toString();
                evvehety.setGlasses(Glasses);
                String Hair = Resultvaljson.optJSONObject("Hair").toString();
                evvehety.setHair(Hair);
                String Hat = Resultvaljson.optJSONObject("Hat").toString();
                evvehety.setHat(Hat);
                String Mask = Resultvaljson.optJSONObject("Mask").toString();
                evvehety.setMask(Mask);
                String RegionName = Resultvaljson.optJSONObject("RegionName").toString();
                evvehety.setRegionname(RegionName);
                String Sex = Resultvaljson.optJSONObject("Sex").toString();
                evvehety.setSex(Sex);
                String Type = Resultvaljson.optJSONObject("Type").toString();
                evvehety.setType(Type);
                evvehety.setDeviceid(mDevic);
                warningresultpersonService.insert(evvehety);
                LOGGER.info("-------- parseMessgedataperson mDevic： " + mDevic + "--------");
            }
            catch (Exception e)
            {

            }
        }
    }
    //解析订阅结构化数据(机动车)
    private void parseMessgedatavehicleinfo(String Resultval,String objpath,String fullpath)
    {
        if (Resultval != null && Resultval.equals("")==false)
        {
            try
            {
                WarningresultvehicleinfoEntity evvehety = new WarningresultvehicleinfoEntity();
                JSONObject Resultvaljson = new JSONObject(Resultval);
                String CarType = Resultvaljson.optJSONObject("CarType").toString();
                evvehety.setCartype(CarType);
                String Chn = Resultvaljson.optString("Chn");
                evvehety.setChn(Chn);
                String CoDriver = Resultvaljson.optJSONObject("CoDriver").toString();
                evvehety.setCodriver(CoDriver);
                String CoNoBelt = Resultvaljson.optJSONObject("CoNoBelt").toString();
                evvehety.setConobelt(CoNoBelt);
                String Color = Resultvaljson.optJSONObject("Color").toString();
                evvehety.setColor(Color);
                String DriveWay = Resultvaljson.optJSONObject("DriveWay").toString();
                evvehety.setDriveway(DriveWay);
                String Drop = Resultvaljson.optJSONObject("Drop").toString();
                evvehety.setDrop(Drop);
                String HasCall = Resultvaljson.optJSONObject("HasCall").toString();
                evvehety.setHascall(HasCall);
                String HasCrash = Resultvaljson.optJSONObject("HasCrash").toString();
                evvehety.setHascrash(HasCrash);
                String HasRack = Resultvaljson.optJSONObject("HasRack").toString();
                evvehety.setHasrack(HasRack);
                String HasSpareTire = Resultvaljson.optJSONObject("HasSpareTire").toString();
                evvehety.setHassparetire(HasSpareTire);
                String HasSunroof = Resultvaljson.optJSONObject("HasSunroof").toString();
                evvehety.setHassunroof(HasSunroof);
                String IsDanger = Resultvaljson.optJSONObject("IsDanger").toString();
                evvehety.setIsdanger(IsDanger);
                String IsSlag = Resultvaljson.optJSONObject("IsSlag").toString();
                evvehety.setIsslag(IsSlag);
                String MainNoBelt = Resultvaljson.optJSONObject("MainNoBelt").toString();
                evvehety.setMainnobelt(MainNoBelt);
                String MarkerNum = Resultvaljson.optJSONObject("MarkerNum").toString();
                evvehety.setMarkernum(MarkerNum);
                String Orientation = Resultvaljson.optJSONObject("Orientation").toString();
                evvehety.setOrientation(Orientation);
                String Paper = Resultvaljson.optJSONObject("Paper").toString();
                evvehety.setPaper(Paper);
                String PlateInfo = Resultvaljson.optJSONObject("PlateInfo").toString();
                evvehety.setPlateinfo(PlateInfo);
                String Rect = Resultvaljson.optJSONArray("Rect").toString();
                evvehety.setRect(Rect);
                String StyleName = Resultvaljson.optString("StyleName");
                evvehety.setStylename(StyleName);
                evvehety.setFullpicpath(fullpath);
                evvehety.setObjpicpath(objpath);
                String Time = Resultvaljson.optString("Time");
                evvehety.setTime(Time);
                String Type = Resultvaljson.optJSONObject("Type").toString();
                evvehety.setType(Type);
                evvehety.setDeviceid(mDevic);
                warningresultvehicleinfoService.insert(evvehety);
                LOGGER.info("-------- parseMessgedatavehicleinfo mDevic： " + mDevic + "--------");
            }
            catch (Exception e)
            {

            }
        }
    }
}
